package com.yitiao.demo100;

/**
 *计算二维数组中各行元素之和并查找其值最大的那个行。
 */
public class question_10 {
    public static void main(String args[]) {
        int myTable[][] = {
                {22, 34, 45, 11, 33, 5, 92},
                {17, 9, 27, 31, 46, 54, 88},
                {98, 81, 64, 62, 15, 14, 23},
                {54, 43, 55, 1, 22, 9, 33}
        };
        int sum, max, maxRow=0;
        max = 0;
        for (int row=0; row<4; row++) {
            sum = 0;
            for (int col=0; col<7; col++)
                sum += myTable[row][col];
            if (sum > max) {
                max = sum;
                maxRow = row;
            }
        }
        System.out.println("Row: " + maxRow + " value: " + max);
    }
}
